<template>
  <view class="commonBox" @click="emits('boxClick')">
    <view class="header">
      <view class="left">
        <view class="headText" v-if="info.name">{{ info?.name[0] + info?.name[1] }}</view>
        <view>
          <view class="nameBox">
            <view class="title">{{ info.name }}</view>
          </view>
          <view class="labelList">
            <view class="item" v-if="info.peopleCount">{{ peopleCountObj[info.peopleCount] }}</view>
          </view>
        </view>
      </view>
      <view class="right" v-if="info.businessStatus">{{ businessStatusObj[info.businessStatus] }}</view>
    </view>
    <view class="infoBox">
      <view>
        <view class="title">法定代表人</view>
        <view class="value">{{ info.legalRepresentative || "未知" }}</view>
      </view>
      <view>
        <view class="title">注册资本</view>
        <view class="value">{{ info.registeredCapital }}</view>
      </view>
      <view>
        <view class="title">成立日期</view>
        <view class="value">{{ info.createDate || "未知" }}</view>
      </view>
    </view>
    <view class="buttomCn" v-if="!isBtn">
      <view class="leftText">已有{{ info.viewedCount }}人查看</view>
      <view class="lookBtn" @click.stop="goPage(`/pages/myPage/MyBusinessCard/MyBusinessCard?cardId=${info?.userId}&pageType=other`)"
        ><u-icon name="chat" color="#fff" size="24"></u-icon><text>查看联系</text>
      </view>
    </view>
    <view class="shBox" v-else>
      <view class="shStatus" :style="{ color: info.status === '3' ? '#F35555' : '#4FCFBB' }">
        {{ info.status === "1" ? "申请中" : info.status === "2" ? "已通过" : "已驳回" }}
      </view>
      <view class="bhBox" v-if="info.status === '3'">
        <view>驳回原因：</view>
        {{ info.reason }}
      </view>
    </view>
  </view>
</template>

<script lang="ts" setup>
import { goPage } from "../utils/commonFn";
const { info, isBtn } = defineProps<{
  info: HomeTypes.factoryList;
  isBtn?: boolean;
}>();
const emits = defineEmits<{ (e: "boxClick"): void }>();

const peopleCountObj: any = {
  "1": "0-20人",
  "2": "20-99人",
  "3": "100-499人",
  "4": "500-999人",
  "5": "1000-9999人",
  "6": "10000人以上",
};
const businessStatusObj: any = {
  "1": "存续",
  "2": "在业",
  "3": "吊销",
  "4": "注销",
  "5": "迁入",
  "6": "迁出",
  "7": "停业",
  "8": "清算",
};
</script>

<style scoped lang="less">
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  .left {
    display: flex;
    align-items: center;
    .headText {
      width: 88rpx;
      height: 88rpx;
      background: #3e81f3;
      border-radius: 8rpx;
      text-align: center;
      line-height: 88rpx;
      font-size: 30rpx;
      font-family: PingFangSC, PingFang SC;
      font-weight: 600;
      color: #ffffff;
      margin-right: 16rpx;
    }
    .nameBox {
      display: flex;
      align-items: center;
      .title {
        width: 280rpx;
        font-size: 30rpx;
        font-family: PingFangSC, PingFang SC;
        font-weight: 600;
        color: #1e1e1e;
        line-height: 42rpx;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
      }
    }
    .labelList {
      display: flex;
      align-items: center;
      margin-top: 6rpx;
      .item {
        background: #e7f1fe;
        border-radius: 2rpx;
        font-size: 22rpx;
        font-family: DINPro, DINPro;
        font-weight: 500;
        color: #1676fd;
        line-height: 28rpx;
        margin-right: 10rpx;
        padding: 8rpx 12rpx;
      }
    }
  }
  .right {
    border: 2rpx solid #4fcfbb;
    font-size: 24rpx;
    font-family: PingFangSC, PingFang SC;
    font-weight: 500;
    color: #4fcfbb;
    line-height: 34rpx;
    padding: 7rpx 12rpx;
    border-radius: 10rpx;
  }
}
.infoBox {
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-align: center;
  padding: 30rpx 10rpx;
  .title {
    font-size: 24rpx;
    font-family: PingFangSC, PingFang SC;
    font-weight: 400;
    color: #bebebe;
    line-height: 34rpx;
  }
  .value {
    font-size: 26rpx;
    font-family: DINPro, DINPro;
    font-weight: 400;
    color: #1e1e1e;
    line-height: 46rpx;
  }
}
.buttomCn {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f5f7f9;
  border-radius: 16rpx;
  padding: 16rpx 24rpx;
  .leftText {
    font-size: 24rpx;
    font-family: PingFangSC, PingFang SC;
    font-weight: 500;
    color: #4fcfbb;
    line-height: 34rpx;
  }
}
.shBox {
  border-top: 1px solid #f5f7f9;
  padding-top: 28rpx;
  .shStatus {
    font-size: 28rpx;
    font-family: PingFangSC, PingFang SC;
    font-weight: 500;
    color: #4fcfbb;
    line-height: 40rpx;
  }
  .bhBox {
    background: #f5f7f9;
    border-radius: 16rpx;
    padding: 24rpx 32rpx;
    font-size: 28rpx;
    font-family: PingFangSC, PingFang SC;
    font-weight: 400;
    color: #1e1e1e;
    line-height: 56rpx;
    margin-top: 30rpx;
  }
}
</style>
